package com.google.android.apps.skipbot;

import roboguice.activity.RoboActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;

public class SkipperActivity extends RoboActivity {
  private static final String TAG = "Skipper";
  RobotService robotService;

  private final ServiceConnection mConnection = new ServiceConnection() {
    @Override
    public void onServiceConnected(ComponentName className, IBinder service) {
      robotService = ((RobotService.LocalBinder) service).getService();
      Log.i(TAG, getString(R.string.robot_service_connected));
      onRobotConnected();
    }

    @Override
    public void onServiceDisconnected(ComponentName className) {
      robotService = null;
      Log.i(TAG, getString(R.string.robot_service_disconnected));
      onRobotDisconnected();
    }
  };

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    robotService = null;
    Intent intent = new Intent(this, RobotService.class);
    startService(intent);
    bindService(new Intent(this, RobotService.class), mConnection, BIND_AUTO_CREATE);
  }

  @Override
  protected void onDestroy() {
    unbindService(mConnection);
    super.onDestroy();
  }

  void onRobotConnected() {
  }

  void onRobotDisconnected() {
  }
}
